﻿<navigation:Page x:Class="ibba.src.noriskbo.views.ViewImportacaoPortfolio" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"            
           xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"            
           xmlns:ig="http://schemas.infragistics.com/xaml"
           xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
           xmlns:vm="clr-namespace:ibba.src.noriskbo.ViewModels"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="800" d:DesignHeight="480"
           Title="ViewImportacaoPortfolio Page">
    
    <navigation:Page.Resources>
        
        <vm:VMImportacaoPortfolio x:Key="ViewModel" />

    </navigation:Page.Resources>

    <Grid x:Name="LayoutRoot" Background="White" Margin="10,3,10,20" DataContext="{Binding Source={StaticResource ViewModel}}">
        <toolkit:BusyIndicator IsBusy="{Binding IsBusy}" BusyContent="{Binding BusyText}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="60"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <StackPanel Orientation="Horizontal" VerticalAlignment="Top" Grid.Row="0">
                    <StackPanel HorizontalAlignment="Left">
                        <Image Source="{StaticResource  IconeTelaImportacao}" Width="52" Height="52" />
                    </StackPanel>

                    <StackPanel Orientation="Vertical" Margin="5,0,0,5" VerticalAlignment="Bottom">
                        <TextBlock Text="{Binding TitleView}" Style="{StaticResource TitleHeader}"/>
                        <Border Style="{StaticResource LineGold}" Margin="0,5" />

                        <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom">
                            <TextBlock Text="Arquivo:" Style="{StaticResource SubTitleHeader}" VerticalAlignment="Center"/>
                            <TextBox Text="{Binding ExcelFileName}" IsReadOnly="True" Style="{StaticResource TextReadOnly}" Margin="5,0,0,0" BorderThickness="0" Foreground="#FF0A739D" />
                        </StackPanel>

                    </StackPanel>

                </StackPanel>

                <Grid HorizontalAlignment="Right" Grid.Row="0">
                    <TextBlock Text="{Binding ProcessingCount}" VerticalAlignment="Center" FontSize="40" FontWeight="Bold" Foreground="#FFB4ADAD" 
                               />
                <!--Visibility="{Binding ProcessingCount, Converter={StaticResource BooleanToVisibilityConverter}}"-->
            </Grid>
            
            <ig:XamGrid x:Name="xgPortfolio" Grid.Row="1" Margin="0,0,0,29" 
                            ItemsSource="{Binding ListaPortfoliosGrid, Mode=TwoWay}" VerticalAlignment="Top"
                            AutoGenerateColumns="False" RowAdding="xgPortfolio_RowAdding" RowEnteringEditMode="xgPortfolio_RowEnteringEditMode" CellExitingEditMode="xgPortfolio_CellExitingEditMode" CellExitedEditMode="xgPortfolio_CellExitedEditMode" RowExitingEditMode="xgPortfolio_RowExitingEditMode" CellEnteringEditMode="xgPortfolio_CellEnteringEditMode" BindingValidationError="xgPortfolio_BindingValidationError" CellEditingValidationFailed="xgPortfolio_CellEditingValidationFailed">
                
                    <i:Interaction.Behaviors>
                    
                </i:Interaction.Behaviors>


                    <ig:XamGrid.ExpansionIndicatorSettings>
                    <ig:ExpansionIndicatorSettings Visibility="Visible" />                     
                </ig:XamGrid.ExpansionIndicatorSettings>

                    

                    <ig:XamGrid.SelectionSettings>
                        <ig:SelectionSettings CellClickAction="SelectRow" RowSelection="Single" />
                    </ig:XamGrid.SelectionSettings>

                    <ig:XamGrid.AddNewRowSettings>
                        
                        <ig:AddNewRowSettings AllowAddNewRow="Top" IsEnterKeyEditingEnabled="True" IsF2EditingEnabled="True" 
                                              IsMouseActionEditingEnabled="SingleClick" IsOnCellActiveEditingEnabled="False" 
                                              Style="{StaticResource AddRowStyling}">
                                                        
                        </ig:AddNewRowSettings>
                        
                    </ig:XamGrid.AddNewRowSettings>

                    <ig:XamGrid.EditingSettings>
                        <ig:EditingSettings AllowEditing="Cell" IsEnterKeyEditingEnabled="True" IsF2EditingEnabled="True"
                                            IsMouseActionEditingEnabled="DoubleClick" IsOnCellActiveEditingEnabled="False"  />
                    </ig:XamGrid.EditingSettings>               
                

                    <ig:XamGrid.Columns>                    
                        
                        
                        
                        <ig:TemplateColumn Key="StatusImportacao" IsResizable="False" >
                            <ig:TemplateColumn.HeaderTemplate>
                                <DataTemplate>
                                    <TextBlock Text="SI" ToolTipService.ToolTip="Status de Importação"/>
                                </DataTemplate>
                            </ig:TemplateColumn.HeaderTemplate>
                            <ig:TemplateColumn.ItemTemplate>
                                <DataTemplate>
                                    <Image 
                    					Width="25" Height="25" ToolTipService.ToolTip="{Binding DescricaoImportacao}"
                    					HorizontalAlignment="Center"
                                        Source="{Binding StatusImportacao, Converter={StaticResource StatusPortImportToImageConverter}}" />
                                </DataTemplate>
                            </ig:TemplateColumn.ItemTemplate>
                        </ig:TemplateColumn>

                        <ig:TextColumn Key="IdISDA" HeaderText="ISDA" Width="100" HeaderStyle="{StaticResource BlueHeaderStyle}" CellStyle="{StaticResource CellColumnStyleDetail}"/>                                                   
                        <ig:TextColumn Key="CdContrato" HeaderText="Contrato" Width="100" HeaderStyle="{StaticResource BlueHeaderStyle}" CellStyle="{StaticResource CellColumnStyleDetail}" />
                        <ig:TextColumn Key="VlThreshold" HeaderText="Threshold" Width="200" HeaderStyle="{StaticResource BlueHeaderStyle}" FormatString="{}{0:N2}" HorizontalContentAlignment="Right" CellStyle="{StaticResource CellColumnStyleDetail}" />
                        <ig:TextColumn Key="VlMTA" HeaderText="MTA" Width="100" HeaderStyle="{StaticResource BlueHeaderStyle}"  FormatString="{}{0:N2}" HorizontalContentAlignment="Right" CellStyle="{StaticResource CellColumnStyleDetail}"/>
                        <ig:TextColumn Key="VlPrazo" HeaderText="Prazo Verific(dc)" Width="110" HeaderStyle="{StaticResource BlueHeaderStyle}"  FormatString="{}{0:N0}" HorizontalContentAlignment="Right" CellStyle="{StaticResource CellColumnStyleDetail}"/>
                        <ig:TextColumn Key="PcHaircut" HeaderText="Haircut" Width="110" HeaderStyle="{StaticResource BlueHeaderStyle}"  FormatString="{}{0:N2}" HorizontalContentAlignment="Right" CellStyle="{StaticResource CellColumnStyleDetail}"/>
                        <ig:TextColumn Key="VlMargem" HeaderText="Margem" Width="200" HeaderStyle="{StaticResource BlueHeaderStyle}"  FormatString="{}{0:N2}" HorizontalContentAlignment="Right" CellStyle="{StaticResource CellColumnStyleDetail}"/>
                        <ig:TextColumn Key="CdMoeda" HeaderText="Moeda" Width="100" HeaderStyle="{StaticResource BlueHeaderStyle}"  HorizontalContentAlignment="Right" CellStyle="{StaticResource CellColumnStyleDetail}" ValueConverter="{StaticResource TextToUpperConverter}" />
                        <!--<ig:DateColumn Key="dtPortfolio" HeaderText="Data" Width="130" HeaderStyle="{StaticResource BlueHeaderStyle}" CellStyle="{StaticResource CellColumnStyle}"/>-->
                        <ig:DateColumn Key="DtIniVig" HeaderText="Data Inicio Vig." Width="130" HeaderStyle="{StaticResource BlueHeaderStyle}" CellStyle="{StaticResource CellColumnStyle}"/>
                        <ig:DateColumn Key="DtFimVig" HeaderText="Data Fim Vig." Width="130" HeaderStyle="{StaticResource BlueHeaderStyle}" CellStyle="{StaticResource CellColumnStyle}"/>
                        
                        <ig:UnboundColumn Key="IdPortfolio" HeaderText=" " Width="Auto" IsFilterable="False" IsGroupable="False" HorizontalContentAlignment="Center" >
                            <ig:UnboundColumn.ItemTemplate>
                                <DataTemplate>
                                    <Button x:Name="btnDelete" Click="btnDelete_Click"  Visibility="{Binding Converter={StaticResource DeleteButtonPortfolioConverter}}">
                                        <Image Source="/ibba.src.noriskbo;Component/Images/delete.png" Width="16" Height="16"/>
                                    </Button>
                                </DataTemplate>
                            </ig:UnboundColumn.ItemTemplate>
                        </ig:UnboundColumn>

                        <ig:TextColumn Key="ClientesInvalidos" Visibility="Collapsed"/>

                        <ig:ColumnLayout Key="ListaClientesGrid" Indentation="68" AutoGenerateColumns="False" >
                            
                            
                            <ig:ColumnLayout.Columns>
                                <ig:TemplateColumn Key="StatusImportacao" IsResizable="False" >
                                    <ig:TemplateColumn.HeaderTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="SV" ToolTipService.ToolTip="Status de Validação"/>
                                        </DataTemplate>
                                    </ig:TemplateColumn.HeaderTemplate>
                                    <ig:TemplateColumn.ItemTemplate>
                                        <DataTemplate>
                                            <Image 
                    					Width="25" Height="25" ToolTipService.ToolTip="{Binding DescricaoImportacao}"
                    					HorizontalAlignment="Center"
                                        Source="{Binding StatusImportacao, Converter={StaticResource StatusPortImportToImageConverter}}" />
                                        </DataTemplate>
                                    </ig:TemplateColumn.ItemTemplate>
                                </ig:TemplateColumn>

                                <ig:TextColumn Key="CdContrato" Width="200" HeaderText="Contrato" />
                                <ig:TextColumn Key="IdCliente" HeaderText="ID Cliente"  Visibility="Collapsed"/>
                                <ig:TextColumn Key="NoCnpjCpf" HeaderText="CGI Cliente" />
                                <ig:TextColumn Key="IdVeiculoLegal" HeaderText="ID Veículo Legal" />
                                <ig:TextColumn Key="NomeCliente" HeaderText="Cliente" IsReadOnly="True" />
                                <ig:TextColumn Key="NomeVeiculoLegal" HeaderText="Veículo Legal" IsReadOnly="True"/>

                                <ig:UnboundColumn Key="IdPortfolioCliente" HeaderText=" " Width="Auto" IsFilterable="False" IsGroupable="False" HorizontalContentAlignment="Center" >
                                    <ig:UnboundColumn.ItemTemplate>
                                        <DataTemplate>
                                            <Button x:Name="btnDelete" Click="btnDelete_Click"  Visibility="{Binding Converter={StaticResource DeleteButtonPortfolioClienteConverter}}">
                                                <Image Source="/ibba.src.noriskbo;Component/Images/delete.png" Width="16" Height="16"/>
                                            </Button>
                                        </DataTemplate>
                                    </ig:UnboundColumn.ItemTemplate>
                                </ig:UnboundColumn>

                            </ig:ColumnLayout.Columns>
                        
                        <ig:ColumnLayout.AddNewRowSettings>
                                <ig:AddNewRowSettingsOverride AllowAddNewRow="Bottom" AddNewRowHeight="28"/>
                            </ig:ColumnLayout.AddNewRowSettings>
                        
                    </ig:ColumnLayout>
                                               
                        

                        
                    </ig:XamGrid.Columns>
                
                </ig:XamGrid> 
                
                <Border Background="#FFEFEFEF" BorderThickness="1,0,1,1" BorderBrush="#FF617583" Height="30" 
                         HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Grid.Row="1" Padding="3" >
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>

                        <HyperlinkButton x:Name="lnkDownload" Content="Baixar Planilha Template" VerticalAlignment="Center" HorizontalAlignment="Left"
                                         Foreground="#FF0E50DE" TargetName="_blank" />

                        <StackPanel Orientation="Horizontal" Grid.Column="1">
                            <StackPanel Orientation="Horizontal" ToolTipService.ToolTip="Indicador de Inclusão de Portfólios ou Clientes">
                                <Image Source="{StaticResource IconePortStatusImportIncluir}" Width="16" Height="16" Margin="0,4,0,0"/>
                                <TextBlock Text="Inclusão" VerticalAlignment="Center" Margin="3,8,25,3" />
                                <sdk:Label Content="{Binding InsertCount}" Style="{StaticResource LegendGreen}" Margin="-182,-18,0,0" />
                            </StackPanel>

                            <StackPanel Orientation="Horizontal" ToolTipService.ToolTip="Indicador de Alteração de Portfólios ou Clientes">
                                <Image Source="{StaticResource IconePortStatusImportAlterar}" Width="16" Height="16" Margin="0,4,0,0"/>
                                <TextBlock Text="Alteração" VerticalAlignment="Center" Margin="3,8,25,3" />
                                <sdk:Label Content="{Binding UpdateCount}" Style="{StaticResource LegendBlue}" Margin="-192,-18,0,0" />
                            </StackPanel>

                            <StackPanel Orientation="Horizontal" ToolTipService.ToolTip="Indicador de Exclusão de Portfólios ou Clientes">
                                <Image Source="{StaticResource IconePortStatusImportExclusao}" Width="16" Height="16" Margin="0,4,0,0" />
                                <TextBlock Text="Exclusão" VerticalAlignment="Center" Margin="3,8,25,3" />
                                <sdk:Label Content="{Binding DeleteCount}" Style="{StaticResource LegendRed}" Margin="-186,-18,0,0" />
                            </StackPanel>

                            <StackPanel Orientation="Horizontal" ToolTipService.ToolTip="Indicador de de Portfólios ou Clientes gravados na base">
                                <Image Source="{StaticResource IconePortStatusImportGravado}" Width="16" Height="16" Margin="0,4,0,0"/>
                                <TextBlock Text="Gravado" VerticalAlignment="Center" Margin="3,8,25,3" />
                                <sdk:Label Content="{Binding OriginalCount}" Style="{StaticResource LegendGray}" Margin="-182,-18,0,0" />
                            </StackPanel>

                            <StackPanel Orientation="Horizontal" ToolTipService.ToolTip="Alertas de validação">
                                <Image Source="{StaticResource IconePortStatusAlerta}" Width="16" Height="16" Margin="0,4,0,0"/>
                                <TextBlock Text="Alertas" VerticalAlignment="Center" Margin="3,8,25,3" />
                                <sdk:Label Content="{Binding AlertCount}" Style="{StaticResource LegendOrange}" Margin="-167,-18,0,0" />
                            </StackPanel>

                            <StackPanel Orientation="Horizontal" ToolTipService.ToolTip="Erros de validação">
                                <Image Source="{StaticResource IconePortStatusErro}" Width="16" Height="16" Margin="0,4,0,0"/>
                                <TextBlock Text="Erros" VerticalAlignment="Center" Margin="3,8,25,3" />
                                <sdk:Label Content="{Binding ErrorCount}" Style="{StaticResource LegendRed}" Margin="-150,-18,0,0" />
                            </StackPanel>

                        </StackPanel>
                        <Path Grid.Column="1" Data="M599.28162,26.499548 L599.38159,-3.5000198" HorizontalAlignment="Right" Margin="0,-3.5,171.618,-4.5" Stretch="Fill" UseLayoutRounding="False" Width="1.1" Fill="#FF637584">
                        	<Path.Stroke>
                        		<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        			<GradientStop Color="#FFEFEFEF" Offset="0"/>
                        			<GradientStop Color="#FF637584" Offset="1"/>
                        		</LinearGradientBrush>
                        	</Path.Stroke>
                        </Path>
                        <Path Data="M231.83878,26.249189 L231.65982,-3.4373939" HorizontalAlignment="Right" Margin="0,-3.437,12.25,-4.25" Stretch="Fill" UseLayoutRounding="False" Width="1.179" Fill="#FF637584">
                        	<Path.Stroke>
                        		<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        			<GradientStop Color="#FFEFEFEF" Offset="0"/>
                        			<GradientStop Color="#FF637584" Offset="1"/>
                        		</LinearGradientBrush>
                        	</Path.Stroke>
                        </Path>
                    </Grid>
                </Border>
                <!--<local:XamGridToolBar x:Name="xgDadosTools" Grid.Row="1" VerticalAlignment="Bottom" Visibility="{Binding Visibility, ElementName=xgDados}"/>-->

                <!--<StackPanel Grid.Row="2" Margin="0,10,0,0" Visibility="Collapsed">
                    <StackPanel Orientation="Horizontal" Margin="0,3" Visibility="Collapsed">
                        <TextBlock Text="Justificativa" Width="100" HorizontalAlignment="Left"  VerticalAlignment="Center"/>
                        <ComboBox Width="350" />
                    </StackPanel>
                    <StackPanel Orientation="Horizontal"  Margin="0,3">
                        <TextBlock Text="Observação" Width="100" HorizontalAlignment="Left"  VerticalAlignment="Top"/>
                        <TextBox Height="40" Width="350"/>
                    </StackPanel>
                </StackPanel>-->
            </Grid>

        </toolkit:BusyIndicator>
    </Grid>
</navigation:Page>
